/**
 * RegisterForm class.
 */
package pits.form;

import java.util.ArrayList;
import java.util.List;

import pits.dao.RegisterDAO;
import pits.util.Constants;

/**
 * @author ltd
 * 
 */
public class RegisterForm {
	private String userName;
	private String password;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public List<String> validate() {
		List<String> errList = new ArrayList<String>();
		RegisterDAO dao = new RegisterDAO();
		if (this.userName.equals(Constants.BLANK_VALUE)) {
			errList.add("Please input Username!");
		}
		if (this.password.equals(Constants.BLANK_VALUE)) {
			errList.add("Please input Password!");
		}
		if (dao.checkUsername(this.userName)) {
			errList.add("This user is already exists! Try with another username!");
		}
		return errList;
	}
}
